﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Chinaer.IDao
{
    public interface IBaseDAO<T>
        where T : class
    {

        /// <summary>
        /// 是否启用追踪
        /// </summary>
        bool EnableTrack
        {
            get;
            set;
        }

        //  int SaveChanges();
        /// <summary>
        /// 通过sql查询
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        IList<T> Query(string sql, int pageIndex, out int recordCount, int pageSize , params System.Data.SqlClient.SqlParameter[] sqlParams);
        /// <summary>
        /// 根据编号获取记录实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T GetByID(string id);
        /// <summary>
        /// 根据编号判断是否存在
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Exists(string id);
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Add(T entity);
        /// <summary>
        /// 更新单个实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Update(T entity);
        /// <summary>
        /// 根据实体来删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        bool Delete(T entity);
        /// <summary>
        /// 根据ID编号来删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Delete(string id);
        /// <summary>
        /// 通过记录编号列表批量删除
        /// </summary>
        /// <param name="listID"></param>
        /// <returns></returns>
        int DeleteByIDs(IList<string> listID);

    }
}
